unit uBreakAes;

interface

uses
  Classes;
  
type
  TBreakAes = class
  private
    FPrefix: string;
    FSuffix: string;
    FCharSet: string;
    FSourceText: string;
    FBoOnlyHunhe: Boolean;
    FBoQuLianCi: Boolean;
    FCiphers: TStringList;    
  public
    constructor Create;
    destructor Destroy; override;

    procedure Execute;    
  end;

  TReadThread = class(TThread)
  protected
    procedure Execute; override;   
  end;

  TWatchDog = class(TThread)
  protected
    procedure Execute; override;  
  end;  
var
  G_BreakAes: TBreakAes;
implementation

uses
  Windows;

var
  G_WatchDog: TWatchDog;

type
  TPROCESS_BASIC_INFORMATION = record
    ExitStatus: DWORD;
    PebBaseAddress: DWORD;
    AffinityMask: DWORD;
    BasePriority: DWORD;
    UniqueProcessId: DWORD;
    InheritedFromUniqueProcessId: DWORD;
  end;
  PPROCESS_BASIC_INFORMATION = ^TPROCESS_BASIC_INFORMATION;
    
function NtQueryInformationProcess(ProcessHandle: THandle; ProcessInformationClass: Byte;
  ProcessInformation: Pointer; ProcessInformationLength: ULONG;ReturnLength: PULONG): DWORD; stdcall; external 'ntdll.dll';
  
{ TBreakAes }

constructor TBreakAes.Create;
begin
  inherited Create;
  FCiphers := TStringList.Create;
end;

destructor TBreakAes.Destroy;
begin
  FCiphers.Free;
  inherited;
end;

procedure TBreakAes.Execute;
begin

end;

{ TWatchDog }

procedure TWatchDog.Execute;
var
  hProcess, hParentProcess: THandle;
  status: DWORD;
  procBaseInfo: TPROCESS_BASIC_INFORMATION;
begin
  hProcess := OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessID);
  if hProcess<>0 then
  begin
    FillChar(procBaseInfo, SizeOf(TPROCESS_BASIC_INFORMATION), 0);
    status := NtQueryInformationProcess(hProcess,
                              0,
                              @procBaseInfo,
                              Sizeof(TPROCESS_BASIC_INFORMATION),
                              nil);
    if status<>0 then
    begin
      hParentProcess := OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, procBaseInfo.InheritedFromUniqueProcessId);
      if hParentProcess<>0 then
      begin
        WaitForSingleObject(hParentProcess, INFINITE);
        ExitProcess(1);
      end;
      CloseHandle(hParentProcess);
    end;
    CloseHandle(hProcess);
  end;
end;

{ TReadThread }

procedure TReadThread.Execute;
begin
  inherited;

end;

initialization
  G_WatchDog := TWatchDog.Create(False);
end.
